package com.sumansoul.multiplerecycleview;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MultipleActivity extends AppCompatActivity {

    public static final int TYPE_TEXT = 0;
    public static final int TYPE_VIDEO = 1;
    public static final int TYPE_PIC = 2;
    public static final int TYPE_PIC2 = 3;
    private RecyclerView rv_list;
    private List<News> mNewsList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multiple);
        rv_list = findViewById(R.id.rv_list);
        initData();
    }

    private void initData() {
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_PIC));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_PIC));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_PIC2));
        mNewsList.add(new News(TYPE_TEXT));
        mNewsList.add(new News(TYPE_VIDEO));
        mNewsList.add(new News(TYPE_PIC2));
        LinearLayoutManager manager = new LinearLayoutManager(this);
        rv_list.setLayoutManager(manager);
        NewsAdapter mNewsAdapter = new NewsAdapter(this, mNewsList);
        rv_list.setAdapter(mNewsAdapter);

    }
}
